<%@ taglib prefix="jstl" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 28101
  Date: 2021/9/22
  Time: 16:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <link href="/css/bootstrap-theme.css" rel="stylesheet">
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <title>管理控制台</title>
    <style>

        th{
            text-align: center;
        }

        td{
            text-align: center;
        }

        .adiv{
            background-color: rgba(255, 178, 0, 0.87);
            width: 80px;
            font-size: 20px;
            margin-top: 30px;
            margin-left: 50px;
            text-align: center;
            border: 1px solid black;
            float: left;
            margin-bottom: 40px;
        }

    </style>
</head>
<body>

    <div class="adiv">
        <a href="jsp/insertCommodity.jsp">新增</a>
    </div>

    <div class="adiv">
        <a href="managerIndex.jsp">主页</a>
    </div>

    <div style="margin-top: 10px;padding: 20px">
        <table class="table table-striped table-hover table-bordered">
            <tr>
                <th hidden="hidden">id</th>
                <th>商品名称</th>
                <th style="width: 300px">商品说明</th>
                <th>商品图片</th>
                <th>商品版本</th>
                <th>商品颜色</th>
                <th>商品管理</th>
            </tr>

            <jstl:if test="${list != null}">

                <jstl:forEach items="${list}" var="commodity">
                    <tr>
                        <td hidden="hidden">${commodity.pid}</td>
                        <td>${commodity.commodityName}</td>
                        <td>${commodity.describetest}</td>
                        <td>
                            <table class="table table-striped table-hover table-bordered">
                                <tr>
                                    <td><a href="/jsp/insertCommodityImgs.jsp?pid=${commodity.pid }&ctid=${commodity.ctid }">新增</a></td>
                                </tr>
                                <jstl:forEach items="${commodity.commodityImgs }" var="commodityImgs">
                                    <jstl:if test="${commodityImgs.isindex == 1}">
                                        <tr>
                                            <td>
                                                <img src="/imgs/${commodityImgs.src } " width="100px" height="110px" />
                                            </td>
                                        </tr>
                                    </jstl:if>
                                </jstl:forEach>
                            </table>
                        </td>
                        <td>
                            <jstl:if test="${commodity.commodityVersion != null }">
                                <table class="table table-striped table-hover table-bordered">
                                    <tr>
                                        <td><a href="/jsp/insertCommodityVersion.jsp?pid=${commodity.pid }">新增</a></td>
                                    </tr>
                                    <tr>
                                        <td>版本名称</td>
                                        <td>原价</td>
                                        <td>现价</td>
                                        <td>数量</td>
                                        <td>管理</td>
                                    </tr>
                                    <jstl:forEach items="${commodity.commodityVersion }" var="commodityVersion">
                                        <tr>
                                            <td>${commodityVersion.versionname } </td>
                                            <td>${commodityVersion.oprice } </td>
                                            <td>${commodityVersion.cprice } </td>
                                            <td>${commodityVersion.num } </td>
                                            <td>
                                                <a href="/CommodityVersionServlet?method=getCommodityVersionByPvid&pvid=${commodityVersion.pvid }" >修改</a>
                                            </td>
                                        </tr>
                                    </jstl:forEach>
                                </table>
                            </jstl:if>
                        </td>
                        <td>
                            <jstl:if test="${commodity.commodityColors != null }">
                                <table class="table table-striped table-hover table-bordered">
                                    <tr>
                                    <tr>
                                        <td><a href="/jsp/insertCommodityColor.jsp?pid=${commodity.pid }">新增</a></td>
                                    </tr>
                                    </tr>
                                    <tr>
                                        <td>颜色</td>
                                        <td>管理</td>
                                    </tr>
                                    <jstl:forEach items="${commodity.commodityColors }" var="commodityColors">
                                        <tr>
                                            <td>${commodityColors.colorname } </td>
                                            <td>
                                                <a href="/CommodityColorServlet?method=getCommodityColorByPcid&pcid=${commodityColors.pcid }" >修改</a>
                                            </td>
                                        </tr>
                                    </jstl:forEach>
                                </table>
                            </jstl:if>
                        </td>

                        <td>
                            <a href="/CommodityServlet?method=getUpdateCommodity&pid=${commodity.pid }">修改</a>
                        </td>
                    </tr>
                </jstl:forEach>
            </jstl:if>

        </table>

        <table align="center" width="40%">
            <tr>
                <th><a href="/CommodityManagerServlet?method=getCommodityByPage&type=${type}&currentPage=1">首页</a></th>
                <th><a href="/CommodityManagerServlet?method=getCommodityByPage&type=${type}&currentPage=${currentPage - 1 < 1 ? 1 : currentPage - 1 }">上一页</a></th>
                <th><em>${currentPage }</em></th>
                <th><a href="/CommodityManagerServlet?method=getCommodityByPage&type=${type}&currentPage=${currentPage + 1 > maxPage ? maxPage : currentPage + 1 }">下一页</a></th>
                <th><a href="/CommodityManagerServlet?method=getCommodityByPage&type=${type}&currentPage=${maxPage }">尾页</a></th>
            </tr>
        </table>
    </div>

    <script src="../js/bootstrap.min.js"></script>

</body>
</html>
